From: Steven Tamm Date: Wed, 28 Jan 2004 06:07:36 +0000 (+0000) Subject: unexecmacos.x (unexec_copy): Do not copy more than was requested (count) X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~24339 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=b6ec113f84ebc6f78f596e38b07d566851c16e81;p=emacs.git unexecmacos.x (unexec_copy): Do not copy more than was requested (count) to prevent overwriting during unexec. --- diff --git a/src/ChangeLog b/src/ChangeLog index 3605169b421..a856ec631ac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-01-27 Steven Tamm + + * unexmacosx.c (unexec_copy): Do not copy more than was + requested to prevent overwriting during unexec. + 2004-01-27 Jan Dj,Ad(Brv * process.c (sigchld_handler): Add comment about not calling malloc. diff --git a/src/unexmacosx.c b/src/unexmacosx.c index b8532325973..b41c586d2e0 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -192,6 +192,7 @@ static int unexec_copy (off_t dest, off_t src, ssize_t count) { ssize_t bytes_read; + ssize_t bytes_to_read; char buf[UNEXEC_COPY_BUFSZ]; @@ -203,7 +204,8 @@ unexec_copy (off_t dest, off_t src, ssize_t count) while (count > 0) { - bytes_read = read (infd, buf, UNEXEC_COPY_BUFSZ); + bytes_to_read = count > UNEXEC_COPY_BUFSZ ? UNEXEC_COPY_BUFSZ : count; + bytes_read = read (infd, buf, bytes_to_read); if (bytes_read <= 0) return 0; if (write (outfd, buf, bytes_read) != bytes_read)